﻿<%@ Page Title="" Language="C#" MasterPageFile="~/PropertyInfo.master" AutoEventWireup="true" CodeFile="Statistics.aspx.cs" Inherits="Property_Info_Statistics" %>
<%@ MasterType VirtualPath="~/PropertyInfo.master" %>
<asp:Content ID="ContentHeader" runat="server" ContentPlaceHolderID="HeaderContentPlaceHolder">
    <title></title>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="SidebarContentPlaceHolder" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" Runat="Server">

<div id="map" style="display:none;"></div>
<script src="Gis.js" type="text/javascript"></script>

<asp:Button ID="CensusBtn1" runat="server" OnClientClick="display_table(1)" Enabled="false" />
<asp:Button ID="CensusBtn2" runat="server" OnClientClick="display_table(2)" Enabled="false"/>
<asp:Button ID="CensusBtn3" runat="server" OnClientClick="display_table(3)" Enabled="false"/>
<asp:Button ID="CensusBtn4" runat="server" OnClientClick="display_table(4)" Enabled="false"/>
<p />

<asp:UpdatePanel ID="StatInitUpdatePanel" runat="server">
<ContentTemplate>
<asp:HiddenField ID="City" runat="server" />
<asp:Button ID="StatInitTriggerBtn" runat="server" OnClick="StatInit" style="display:none;"/>
<div id="census_div1" style="display:;">
<h2><asp:Literal ID="CensusTableTitle1" runat="server" Text="Loading..."></asp:Literal></h2>
<asp:Literal ID="CensusTable1" runat="server" Text="Loading..."></asp:Literal>
</div>
<div id="census_div2" style="display:none;">
<h2><asp:Literal ID="CensusTableTitle2" runat="server" Text="Loading..."></asp:Literal></h2>
<asp:Literal ID="CensusTable2" runat="server" Text="Loading..."></asp:Literal>
</div>
<div id="census_div3" style="display:none;">
<h2><asp:Literal ID="CensusTableTitle3" runat="server" Text="Loading..."></asp:Literal></h2>
<asp:Literal ID="CensusTable3" runat="server" Text="Loading..."></asp:Literal>
</div>
<div id="census_div4" style="display:none;">
<h2><asp:Literal ID="CensusTableTitle4" runat="server" Text="Loading..."></asp:Literal></h2>
<asp:Literal ID="CensusTable4" runat="server" Text="Loading..."></asp:Literal>
</div>
</ContentTemplate>
</asp:UpdatePanel>

<script type="text/javascript">

    function load() {
        getCity("map", "<%=Master.PropertyLat%>", "<%=Master.PropertyLng%>");
    }

    function getCity(div_id, property_lat, property_lng) {
        map = new GMap2(document.getElementById(div_id));
        var property_loc = new GLatLng(property_lat, property_lng);
        map.setCenter(property_loc);
        
        var geocoder = new GClientGeocoder();
        geocoder.setBaseCountryCode("us");
        geocoder.getLocations(property_loc, function(point) {
            if (!point || point.Status.code != 200) {

            }
            else {
                var address = point.Placemark[0].address;
                var i = address.indexOf(",");
                address = address.substring(i + 2);
                i = address.indexOf(",");
                var city = address.substring(0, i);
                document.getElementById("<%=City.ClientID%>").value = city;
                document.getElementById("<%=StatInitTriggerBtn.ClientID%>").click();
                
            }
        });
    }  
    
    function display_table(no, btn) {
        var div = "census_div" + no;

        if (document.getElementById(div).style.display == "none") {
            for (var i = 1; i <= 4; i++) {
                div = "census_div" + i;
                document.getElementById(div).style.display = "none";
            }
            div = "census_div" + no;
            document.getElementById(div).style.display = "";
        }
    }
    var browser = navigator.appName;
    if (browser == "Microsoft Internet Explorer") {
        document.body.onload = load;
    }
    else {
        document.body.onload = load();
    }
    document.body.onunload = GUnload;
</script>
</asp:Content>

